package com.csii.activiti.server.abstraction.ipml;

import com.csii.activiti.server.abstraction.entity.ActDept;
import com.csii.activiti.server.abstraction.service.ActDeptService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class ActDeptServiceImpl implements ActDeptService {

    private List<ActDept> depts = new ArrayList<>();

    {
        depts.add(new ActDept("部门1","code1"));
        depts.add(new ActDept("部门2","code2"));
        depts.add(new ActDept("部门3","code3"));
        depts.add(new ActDept("部门4","code4"));
        depts.add(new ActDept("部门5","code5"));
        depts.add(new ActDept("部门6","code6"));
        depts.add(new ActDept("部门7","code7"));
        depts.add(new ActDept("部门8","code8"));
        depts.add(new ActDept("部门9","code9"));
        depts.add(new ActDept("部门10","code10"));


    }
    @Override
    public List<ActDept> queryDeptLikeDeptName(String deptName) {
        return depts.stream().filter(item->item.getDeptName().contains(deptName)).collect(Collectors.toList());
    }

    @Override
    public List<ActDept> queryDeptByDeptCodes(Set<String> deptCodes) {
        return depts.stream().filter(item->deptCodes.contains(item.getDeptCode())).collect(Collectors.toList());
    }
}
